<template>
	<view class="Menu">
		<!-- 导航条 :style="{ height: $wanlshop.wanlsys().height + 'px' }"-->
		<view class="cu-custom">
			<view class="cu-bar fixed" style="background: #fff;"
				:style="{height: $wanlshop.wanlsys().height + 'px',paddingTop: $wanlshop.wanlsys().top + 'px',}">
				<view class="action">
					<text class="wlIcon-fanhui1" style="margin-left: 0" @tap="$wanlshop.back(1)"></text>
				</view>
				<view class="content" :style="{ top: $wanlshop.wanlsys().top + 'px' }">
					<!-- 提取 -->
					{{$t('otcExtract.page.title')}}
				</view>
				<view class="action" @tap="$wanlshop.auth('/pages/newPage/order')">
					提取记录
					<!-- <text class="wlIcon-gengduo" @tap="showModal('share')"></text> -->
				</view>
			</view>
		</view>
		<view style="position: fixed;height: auto;  width: auto; top: 0; left: 0; bottom: 0; right: 0;"
			:style="{top: $wanlshop.wanlsys().height + 'px',}">
			<view class="transferBox">
				<view class="formList">
					<h1>{{$t('otcExtract.input.rechargeNetwork.title')}}<!-- 充值网络 --></h1>
					<view class="list">USDT-BSC20</view>
				</view>
				<view class="formList">
					<h1>USDT{{$t('otcExtract.input.extractAddress.title')}}<!-- 提取地址 --></h1>
					<view class="list">

						<!-- 请输入USDT提取地址 -->
						<u--input border='none' v-model="wallet_address"
							:placeholder="$t('otcExtract.input.extractAddress.placeholder')"></u--input>
					</view>
				</view>
				<view class="formList">
					<h1>USDT{{$t('otcExtract.input.extractNumber.title')}}<!-- 提取数量 -->
						<p><!-- 余额 -->{{$t('otcExtract.input.extractNumber.subtitle')}}:{{money||0}}</p>
					</h1>
					<view class="list">

						<!-- otcExtract.input.extractNumber.placeholder -->
						<u--input border='none' v-model="amount"
							:placeholder="$t('otcExtract.input.extractNumber.placeholder')"></u--input>
					</view>
				</view>
			</view>
			<view style="height: 40rpx; background: #f8f8f8;"></view>
			<!-- 			<view class="Tips">
				<h1>充值提示</h1>
				<p>· 请通过钱包BSC网络将USDT转账至上方指定地址 </p>
				<p>· 请确认您的充值地址及充值网络，若地址不正确您的资产将会丢失 </p>
				<p>· 充值完成后需等待网络确认完成后到账，请耐心等待</p>
			</view> -->
			<view class="Tips">
				<h1><!-- 充值提示 -->{{$t('otcExtract.tips.rechargeHint.title')}}</h1>
				<view v-html="html"></view>
			</view>
			<view class="uni-btn">
				<button class="uni-btn-v" @click="formSubmit">{{$t('otcExtract.but.submit')}}<!-- 提交审核 --></button>
			</view>
		</view>
		<u-popup :show="popup_show" mode="center" :safeAreaInsetBottom="false" :mask-close-able="false"
			bgColor="#ffffff" round="15" @close="close">
			<view class="popup">
				<view class="popup-wrap">
					<view class="title-line">
						<text class="title">修改昵称</text>
					</view>
					<view class="content">
						<view class="list">
							<u--input v-model="nickname" placeholder="请输入昵称"></u--input>
						</view>
					</view>
					<view class="btn-list">
						<view class="btn-reset" @click="close">取消</view>
						<view class="btn-complete" @click="comit">确定</view>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>
<script>
	export default {

		data() {
			return {
				wallet_address: '',
				amount: '',
				money: '0',
				html: '',
				popup_show: false,
				nickname: ''
			};
		},
		onShow() {
			this.getMoney()
			this.ExtractDesc()
		},
		methods: {
			//获取余额
			getMoney() {
				uni.request({
					url: "/user/getMoney",
					method: 'POST',
					data: {
						type: '4',
					},
					success: (res) => {
						if (res.res.code == 1) {
							this.money = res.res.data.money
						}
					},
				});
			},
			//提取提示
			ExtractDesc() {
				uni.request({
					url: "/wanlshop/otc/my/usdtExtractDesc",
					method: 'POST',
					data: {
						type: '5',
					},
					success: (res) => {
						if (res.res.code == 1) {
							this.html = res.res.data.desc
						}
					},
				});
			},
			formSubmit() {
				if (this.wallet_address == '') {
					uni.showToast({
						title: '请输入USDT提取地址',
						icon: 'none'
					})
					return
				}
				if (this.amount == '') {
					uni.showToast({
						title: '请输入USDT提取数量',
						icon: 'none'
					})
					return
				}
				uni.request({
					url: "/wanlshop/otc/my/userExtraction",
					method: 'POST',
					data: {
						wallet_address: this.wallet_address,
						amount: this.amount,
					},
					success: (res) => {
						if (res.res.code == 1) {
							this.$wanlshop.msg(res.res.msg);
						} else if (res.res.code == '506') {
							this.popup_show = true
						}
					},
				});
			},
			close() {
				this.popup_show = false
			},
			comit() {
				if (this.nickname == '') {
					uni.showToast({
						title: '请输入昵称',
						icon: 'none'
					})
					return
				}
				uni.request({
					url: "/user/upnickname",
					method: 'POST',
					data: {
						nickname: this.nickname,
					},
					success: (res) => {
						if (res.res.code == 1) {
							this.$wanlshop.msg(res.res.msg);
							this.popup_show = false
						}
					},
				});
			}
		}
	};
</script>

<style lang="scss">
	.Menu {
		.transferBox {
			padding: 0 24rpx;

			.formList {
				h1 {
					font-weight: 400;
					font-size: 24rpx;
					color: #333333;
					line-height: 48rpx;
					margin: 30rpx 0;
					display: flex;
					align-items: center;
					justify-content: space-between;

					p {
						font-size: 24rpx;
						color: #999999;
					}
				}

				.list {
					background: #fff;
					border-radius: 16rpx;
					padding: 30rpx;
					position: relative;
				}

				/deep/.u-input__content {


					.u-input__content__field-wrapper__field {
						font-weight: 400;
						font-size: 28rpx !important;
						color: #333333 !important;
					}
				}
			}
		}



		.Tips {
			background: #fff;
			padding: 0 24rpx 20rpx 24rpx;

			h1 {
				width: 224rpx;
				height: 100rpx;
				background: url('../../static/images/otc/bg.png') center no-repeat;
				background-size: cover;
				margin: 0 auto;
				font-size: 28rpx;
				color: #333333;
				text-align: center;
				line-height: 100rpx;
			}

			p {
				font-size: 28rpx;
				color: #666666;
				line-height: 56rpx;
			}
		}

		.uni-btn-v {
			width: 702rpx;
			height: 96rpx;
			background: #eb5641;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			margin-top: 40rpx;
			font-weight: 400;
			font-size: 28rpx;
			color: #ffffff;
			line-height: 96rpx;
			margin: 40rpx 24rpx 0 24rpx;
		}
	}

	.popup {
		width: 690rpx;
		padding: 20rpx 0;
	}

	.popup-wrap {
		background: #ffffff;
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		border-radius: 20rpx;

		.title-line {
			display: flex;
			align-items: center;
			justify-content: center;
			position: relative;

			.title {
				margin: 0 auto;
				line-height: 130rpx;
				font-size: 38rpx;
				color: #000000;
				font-weight: bold;
			}

		}


		.content {
			padding: 0rpx 30rpx;

			.list {
				background: #fff;
				border-radius: 16rpx;
				padding: 20rpx;
				position: relative;
			}

			/deep/.u-input__content {


				.u-input__content__field-wrapper__field {
					font-weight: 400;
					font-size: 28rpx !important;
					color: #333333 !important;
				}
			}
		}



	}

	.btn-list {
		width: 100%;
		height: 150rpx;
		background: #FEFFFE;
		box-shadow: 0rpx 0rpx 4rpx 0rpx rgba(0, 0, 0, 0.1);
		display: flex;
		align-items: center;
		justify-content: space-around;

		.btn-reset {
			width: 100%;
			margin: 20rpx 20rpx 0;
			height: 96rpx;
			background: #f4f4f4;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			font-size: 30rpx;
			color: #3E3E3E;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.btn-complete {
			width: 100%;
			margin: 20rpx 20rpx 0;
			height: 96rpx;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			font-size: 30rpx;
			color: #FFFFFF;
			background-color: #FD430E;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
</style>